package com.itheima.day30.demo04;

import com.itheima.day30.demo02.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.junit.Test;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;

public class test {
    @Test
    public void show1() {
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());
        String sql = "";
    }

    @Test
    public void show2() {
        Connection con = null;
        PreparedStatement preparedStatement = null;
        try {
            con = DruidUtils.getConnection();
            String sql1 = "insert into  student values(null,'13',12,'sdf'),(null,'13',12,'sdf'),(null,'13',12,'sdf');";
            String sql2 = "";
            String sql3 = "";
            String sql4 = "";
            preparedStatement = con.prepareStatement(sql1);
            preparedStatement.addBatch(sql1);
            preparedStatement.executeBatch();
            preparedStatement.clearBatch();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DruidUtils.release(con, preparedStatement);
        }
    }

    @Test
    public void show3() {
        Connection con = null;
        Statement stat = null;
        try {
            con = DruidUtils.getConnection();
            stat = con.createStatement();
            String sql1 = "insert into  student values(null,'13',12,'sdf'),(null,'13',12,'sdf'),(null,'13',12,'sdf');";
            String sql2 = "";
            String sql3 = "";
            String sql4 = "";
            stat.addBatch(sql1);
            stat.addBatch(sql1);
            final int[] ints = stat.executeBatch();
            for (int i : ints) {
                System.out.println(i);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }
    }
}
